const router = require('koa-router')()
const { exec } = require('../db')

router.get('/getList', async (ctx, next) => {
  const { pageIndex, pageSize } = ctx.query
  let sql = `SELECT * FROM juejin LIMIT ${pageIndex},${pageSize}`
  let totalsql=`SELECT * FROM juejin`
  const data =await exec(sql)
  const total=await exec(totalsql)
  ctx.body = {
    code:200,
    data,
    total:total.length
  }
})
router.delete('/delList',async(ctx,next)=>{
  console.log(ctx.query)
  const {id}=ctx.query
  let sql=`DELETE FROM juejin WHERE juejin . id= ${id}`
  await exec(sql)
  ctx.body=('删除成功')
})



module.exports = router
